import testRouter from "./modules/index.js"
import componentsRouter from "./modules/components.js"
import vuetify from "./modules/vuetify.js"
import Layout from '@/layout'
// 由于懒加载页面太多的话会造成webpack热更新太慢，所以开发环境不使用懒加载，只有生产环境使用懒加载
const _import = require('@/utils/util.import.' + process.env.NODE_ENV)

const frameIn = [
  {
    path: '/',
    redirect: { name: 'index' },
    component: Layout,
    children: [
      // 首页
      {
        path: 'index',
        name: 'index',
        meta: {
          title: '首页',
          auth: true
        },
        component: _import('system/index')
      },
      // 个人中心
      {
        path: 'mine',
        name: 'mine',
        meta: {
          title: '个人中心',
          auth: true
        },
        component: _import('system/mine')
      },
      // 刷新页面 必须保留
      {
        path: 'refresh',
        name: 'refresh',
        hidden: true,
        component: _import('system/function/refresh')
      },
      // 页面重定向 必须保留
      {
        path: 'redirect/:route*',
        name: 'redirect',
        hidden: true,
        component: _import('system/function/redirect')
      }
    ]
  },
  testRouter,
  componentsRouter,
  vuetify
]

const frameOut = [
  // 登录
  {
    path: '/login',
    name: 'login',
    component: _import('system/login')
  }
]
/**
 * 错误页面
 */
const errorPage = [
  {
    path: '*',
    name: '404',
    component: _import('system/error/404')
  }
]


// 导出需要显示菜单的
export const frameInRoutes = frameIn

export default [
  ...frameIn,
  ...frameOut,
  ...errorPage
]
